<%@ page import="com.mlt.back.service.impl.CategoryServiceImpl" %>
<%@ page import="com.mlt.back.beans.Category" %>
<%@ page import="java.util.List" %>
<%@ page import="com.mlt.back.service.impl.GoodServiceImpl" %>
<%@ page import="com.mlt.back.beans.Good" %>
<%@ page contentType="text/html;charset=UTF-8"%>
<%
    CategoryServiceImpl categoryService = new CategoryServiceImpl();
    GoodServiceImpl goodService = new GoodServiceImpl();
    List<Category> categories = categoryService.selectAll();
    List<Good> goods = null;

    String categoryId = request.getParameter("categoryId");
    if (categoryId == null || categoryId.isEmpty()){
        goods = goodService.list();
    }else {
        goods = goodService.listByCategory(categoryId);
    }
%>

<html>
<head>
    <title>分类产品页面</title>
</head>
<body>
<!--分类列表-->
<div style="width: 30%;float: left;">
    <div>
        <h4>产品所属分类</h4>
    </div>
    <div>
        <ul>
            <li><a href="category_good.jsp">全部</a></li>
            <%for (Category category : categories) {%>
            <li><a href="category_good.jsp?categoryId=<%=category.getCategory_id()%>"><%=category.getCategory_name()%></a></li>
            <%}%>
        </ul>
    </div>
</div>
<!--列表展示-->
<div style="width: 70%;float: left;margin-top: 50px;">
    <table id="tab01" border="1px solid #ccc" cellspacing="0" cellpadding="0">
        <thead>
        <tr>

            <th width="25px"><label><input type="checkbox"><span></span></label></th>
            <th width="80px">产品编号</th>
            <th width="250px">产品名称</th>
            <th width="100px">参考回收价</th>
            <th width="180px">最低回收价</th>

        </tr>
        </thead>
        <tbody style="text-align: center;">
        <%for (Good good : goods) {%>
        <tr>
            <td width="25px"><label><input type="checkbox"><span></span></label></td>
            <td width="80px"><%=good.getGood_id()%></td>
            <td width="250px"><%=good.getGood_name()%></td>
            <td width="100px"><%=good.getGood_cost()%></td>
            <td width="100px"><%=good.getGood_min_price()%></td>
        </tr>
        <%}%>
        </tbody>
    </table>
</div>
</body>
</html>
